﻿using System;
using System.Collections;
using System.IO;

/// <summary>
/// Parent class representing a set of data files
/// </summary>
public class FileCollection : IEnumerable
{
    FileDefinition[] files;

    /// <summary>
    /// Creates the list of data files used by the project
    /// </summary>
    public FileCollection()
    {
        files = new FileDefinition[] {
            // the files representing %ETHNICITY
            new DataFileDefinition(Ethnicity.All,                         Field.Population, "% Overall"),
            new DataFileDefinition(Ethnicity.White,                       Field.Population, "% White"),
            new DataFileDefinition(Ethnicity.Latino,                      Field.Population, "% Latino"),
            new DataFileDefinition(Ethnicity.AfricanAmerican,             Field.Population, "% AA"),
            new DataFileDefinition(Ethnicity.AsianPacificIslander,        Field.Population, "% API"),
            new DataFileDefinition(Ethnicity.AlaskanNativeAmericanIndian, Field.Population, "% ANAI"),

            // the files representing data for ALL
            new DataFileDefinition(Ethnicity.All, Field.Age, "Average Age"),
            new DataFileDefinition(Ethnicity.All, Field.Income, "Average Income"),
            new DataFileDefinition(Ethnicity.All, Field.Veteran, "% Veteran"),
            new DataFileDefinition(Ethnicity.All, Field.Children, "% Children"),
            new DataFileDefinition(Ethnicity.All, Field.Education, "% Education"),

            // the files representing data for WHITE
            new DataFileDefinition(Ethnicity.White, Field.Age, "W Average Age"),
            new DataFileDefinition(Ethnicity.White, Field.Income, "W Average Income"),
            new DataFileDefinition(Ethnicity.White, Field.Veteran, "W % Veteran"),
            new DataFileDefinition(Ethnicity.White, Field.Children, "W % Children"),
            new DataFileDefinition(Ethnicity.White, Field.Education, "W % Education"),

            // LATINO
            new DataFileDefinition(Ethnicity.Latino, Field.Age, "L Average Age"),
            new DataFileDefinition(Ethnicity.Latino, Field.Income, "L Average Income"),
            new DataFileDefinition(Ethnicity.Latino, Field.Veteran, "L % Veteran"),
            new DataFileDefinition(Ethnicity.Latino, Field.Children, "L % Children"),
            new DataFileDefinition(Ethnicity.Latino, Field.Education, "L % Education"),

            // AFRICAN AMERICAN
            new DataFileDefinition(Ethnicity.AfricanAmerican, Field.Age, "AA Average Age"),
            new DataFileDefinition(Ethnicity.AfricanAmerican, Field.Income, "AA Average Income"),
            new DataFileDefinition(Ethnicity.AfricanAmerican, Field.Veteran, "AA % Veteran"),
            new DataFileDefinition(Ethnicity.AfricanAmerican, Field.Children, "AA % Children"),
            new DataFileDefinition(Ethnicity.AfricanAmerican, Field.Education, "AA % Education"),

            // ASIAN PACIFIC ISLANDER
            new DataFileDefinition(Ethnicity.AsianPacificIslander, Field.Age, "API Average Age"),
            new DataFileDefinition(Ethnicity.AsianPacificIslander, Field.Income, "API Average Income"),
            new DataFileDefinition(Ethnicity.AsianPacificIslander, Field.Veteran, "API % Veteran"),
            new DataFileDefinition(Ethnicity.AsianPacificIslander, Field.Children, "API % Children"),
            new DataFileDefinition(Ethnicity.AsianPacificIslander, Field.Education, "API % Education"),

            // ANAI
            new DataFileDefinition(Ethnicity.AlaskanNativeAmericanIndian, Field.Age, "ANAI Average Age"),
            new DataFileDefinition(Ethnicity.AlaskanNativeAmericanIndian, Field.Income, "ANAI Average Income"),
            new DataFileDefinition(Ethnicity.AlaskanNativeAmericanIndian, Field.Veteran, "ANAI % Veteran"),
            new DataFileDefinition(Ethnicity.AlaskanNativeAmericanIndian, Field.Children, "ANAI % Children"),
            new DataFileDefinition(Ethnicity.AlaskanNativeAmericanIndian, Field.Education, "ANAI % Education"),
        };
    }

    /// <summary>
    /// Gets the count of files contained in this object.
    /// </summary>
    public int Count
    {
        get { return files.Length; }
    }

    /// <summary>
    /// Gets the file definition with the given index
    /// </summary>
    /// <param name="i"></param>
    /// <returns></returns>
    public FileDefinition this[int i]
    {
        get { return files[i]; }
    }

    /// <summary>
    /// Support foreach
    /// </summary>
    /// <returns></returns>
    public IEnumerator GetEnumerator()
    {
        return files.GetEnumerator();
    }
}